﻿<%@ WebHandler Language="C#" Class="Getimg" %>


using System;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

public class Getimg : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        string id = context.Request.QueryString["id"];
        AppSettingsReader _configReader = new AppSettingsReader();
        SqlConnection conn = new SqlConnection(_configReader.GetValue("Main.ConnectionString", typeof(string)).ToString());
        SqlCommand cmd = new SqlCommand("select Album_Content from t_Album where Album_ID='" + id + "'", conn);
        conn.Open();
        SqlDataReader dr = cmd.ExecuteReader();

        if (dr.Read())
        {
            context.Response.BinaryWrite((byte[])dr
            ["Album_Content"]);
        }

        dr.Close();
        conn.Close();
        cmd.Dispose();
    }


    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}